
<script>
export default {
  name: 'Dyndaterange',
  // model: {
  //   prop: 'name',
  //   event: 'input'
  // },
  props: {
    // name: {
    //   type: [Array, Object, String, Number],
    //   default: () => ([])
    // },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      timer: null
    }
  },
  methods: {
    handlerSelect(value) {
      // 转化时间保持
      // const timer = handleTime('startTime', 'endTimer', value)
      // this.$emit('input', value)
      this.timer = value
      // 执行事件对象
      this.item.event && this.item.event(value)
    }
  },
  render: function(h) {
    return (
      this.item.render ? this.item.render()
        : <el-date-picker
          // default-value={this.item.defaultValue}
          value={this.timer}
          on-input={this.handlerSelect.bind(this)}
          type='datetimerange'
          placeholder={'请选择' + `${this.item.label}`}
          start-placeholder={this.$t('StartDate')}
          end-placeholder={this.$t('EndDate')}
          value-format={this.item.valueFormat ? this.item.valueFormat : 'yyyy-MM-dd HH:mm:ss'}
          format={this.item.valueFormat ? this.item.valueFormat : 'yyyy-MM-dd HH:mm:ss'}
          default-time={['00:00:00', '23:59:59']}>
        </el-date-picker>
    )
  }
}
</script>
